# !/usr/bin/env python
# -*- coding:utf-8 -*-
import re

class dataModel(object):
    def __init__(self, structuredData):
        self.house_floor = self._house_floor(structuredData.get("house_floor"))  # 只显示 高中低
        self.house_hall = structuredData.get("house_hall")
        self.cityarea_id = structuredData.get("cityarea_id")
        self.house_totalarea = structuredData.get("house_totalarea")
        self.house_price = float(structuredData.get("house_price"))
        self.house_room = structuredData.get("house_room")
        self.cityarea2_id = structuredData.get("cityarea2_id")
        self.borough_id = structuredData.get("borough_id")
        self.house_topfloor = structuredData.get("house_topfloor")

    def getDictData(self):
        try:
            # todo 必填字段验证

            return self.__dict__

        except Exception, e:
            pass

    def _house_floor(self, data):
        if data == "0" or not data: return ""

        result = ""
        if re.match(r'^\d+$', data):
            hfloor = int(data)
            if hfloor < 6: result = "低"
            elif hfloor < 10: result = "中"
            elif hfloor >= 10: result = "高"
        else:result = data

        return result
